
package com.joysuch.wwyt.bp.enums;

public enum ChangeRecordStates {

    INITIAL(0, "待申请"), WAITING_FOR_AUDIT(1, "待审核"), AUDIT_SUCCESS(2, "审核通过"), AUDIT_FAILED(3, "审核不通过"),;

    private int id;
    private String name;

    private ChangeRecordStates(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static ChangeRecordStates findByName(String name) {
        ChangeRecordStates[] values = ChangeRecordStates.values();
        for (ChangeRecordStates v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static ChangeRecordStates findById(Integer level) {
        ChangeRecordStates[] values = ChangeRecordStates.values();
        for (ChangeRecordStates v : values) {
            if (v.getId() == level) {
                return v;
            }
        }
        return null;
    }

    public static String findNameById(Integer id) {
        if (id == null) {
            return null;
        }
        ChangeRecordStates[] values = ChangeRecordStates.values();
        for (ChangeRecordStates v : values) {
            if (v.getId() == id) {
                return v.getName();
            }
        }
        return null;
    }
}
